package edu.bu.cs673.superkids123.parents.controller;

import edu.bu.cs673.superkids123.AbstractController;
import edu.bu.cs673.superkids123.AbstractFrame;
import edu.bu.cs673.superkids123.common.DataObjectAccess.ParentManager;
import edu.bu.cs673.superkids123.common.model.Parent;
import edu.bu.cs673.superkids123.common.view.LoginView;
import edu.bu.cs673.superkids123.parents.view.CreateParentView;
import edu.bu.cs673.superkids123.parents.view.ParentSettingsView;

public class CreateParentController extends AbstractController {

	private Parent current;

	public CreateParentController(AbstractFrame mainFrame) {
		super(mainFrame);
	}

	public void createParent(Parent parent) {
		// Perform add after check
		if (authController.areParentsInitialized()) {
			ParentManager.addParent(parent);
			getMainFrame().changeView(ParentSettingsView.class);
		} else {
			ParentManager.addParent(parent);
			getMainFrame().changeView(LoginView.class);
		}
	}

	public void updateParent(Parent parent) {
		ParentManager.updateParent(parent);
		getMainFrame().changeView(ParentSettingsView.class);
	}

	public void createParent() {
		current = null;
		getMainFrame().changeView(CreateParentView.class);
	}
	
	public Parent current() {
		return current;
	}

	public void editAccount(Parent parent) {
		current = parent;
		getMainFrame().changeView(CreateParentView.class);
	}

}
